package com.an.framework.security.deal;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

/**
 * ClassName: LoginSuccessHandler <br/>
 * Function: 登录成功处理器. <br/>
 * Reason: 登录成功处理器. <br/>
 * date: 2017年11月8日 下午7:17:24 <br/>
 *
 * @author atc
 * @version 1.0.0
 * @since JDK 1.8
 */
public class MyLoginSuccessHandler implements AuthenticationSuccessHandler {

	/**
	 * log:日志.
	 * 
	 * @since JDK 1.8
	 */
	private static final Logger log = LoggerFactory.getLogger(MyLoginSuccessHandler.class);

	/**
	 * 登录成功处理.
	 * 
	 * @see org.springframework.security.web.authentication.AuthenticationSuccessHandler#onAuthenticationSuccess(javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse,
	 *      org.springframework.security.core.Authentication)
	 */
	public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse respose,
			Authentication authentication) throws IOException, ServletException {
		log.debug("用户登录成功，根据权限跳转到不同页面");
		request.getRequestDispatcher("user/login.success").forward(request, respose);
	}

}
